<?php
require_once '../lib/standard.php';
unset($_SESSION['tl_login']);
Page::data();
set_globals();

$globals->perastike_check('login');
$login = $globals->asfales($_REQUEST['login']);

$globals->perastike_check('onoma');
$onoma = $globals->asfales($_REQUEST['onoma']);

$globals->perastike_check('email');
if ($_REQUEST['email'] == '') {
	$email = 'NULL';
}
else {
	$globals->email_check($_REQUEST['email']);
	$email = "'" . $globals->asfales($_REQUEST['email']) . "'";
}

$globals->perastike_check('password');
$password = $globals->asfales($_REQUEST['password']);

$query = "INSERT INTO `pektis` (`login`, `onoma`, `email`, `password`, `poll`) VALUES ('" .
	$login . "', '" . $onoma . "', " . $email . ", '" . sha1($password) . "', NOW())";
$result = @mysqli_query($globals->db, $query);
if (@mysqli_errno($globals->db) == 1062) {
	$globals->klise_fige("Login name not available");
}
if (@mysqli_affected_rows($globals->db) != 1) {
	$globals->klise_fige('Signup failed (' . @mysqli_error($globals->db) . ')');
}
$_SESSION['tl_login'] = $_REQUEST['login'];
?>
